package com.demo2do.fms.entity.supplier.common;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;

import com.demo2do.core.format.PersistentFormat;

/**
 * 关键岗位信息
 * 
 * @author zhonghui
 * 
 */
@Entity
@Table(name = "FMS_SUPPLIER_STAFF")
public class SupplierStaff {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator")
    @SequenceGenerator(name = "generator", sequenceName = "HIBERNATE_SEQUENCE", allocationSize = 1)
    private Long id;

    /** 所属供方 */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @PersistentFormat
    private Supplier supplier;

    /**
     * 关键岗位信息
     * (原始数据是一个关键岗位对应一个字段)
     * 
     * 该枚举我们自己定义
     */
    @Enumerated(EnumType.ORDINAL)
    private KeyPost keyPost;

    /** 姓名 */
    private String name;

    /** 电话 */
    private String telephone;

    /** 手机 */
    private String mobile;

    /** Email */
    private String email;

    /** QQ */
    private String tencent;

    private Long creator;
    
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    private Long lastOperator;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastModifyTime;
    
    @Column(name = "IS_DISABLED")
    private Boolean disabled;

    /**
     * Instantiates a new Supplier staff.
     */
    public SupplierStaff() {
    }

    /**
     * @param supplier
     * @param operator
     * @return
     */
    public SupplierStaff initialzie(Supplier supplier, Long operator) {
        this.supplier = supplier;
        this.creator = operator;
        this.createTime = new Date();
        this.lastOperator = operator;
        this.lastModifyTime = new Date();
        this.disabled = false;
        return this;
    }
    
    /**
     * @param operator
     * @return
     */
    public SupplierStaff edit(Long operator) {
        this.lastOperator = operator;
        this.lastModifyTime = new Date();
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the supplier
     */
    public Supplier getSupplier() {
        return supplier;
    }

    /**
     * @return the keyPost
     */
    public KeyPost getKeyPost() {
        return keyPost;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @return the telephone
     */
    public String getTelephone() {
        return telephone;
    }

    /**
     * @return the mobile
     */
    public String getMobile() {
        return mobile;
    }

    /**
     * @return the email
     */
    public String getEmail() {
        return email;
    }

    /**
     * @return the tencent
     */
    public String getTencent() {
        return tencent;
    }

    /**
     * @return the disabled
     */
    public Boolean getDisabled() {
        return disabled;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the creator
     */
    public Long getCreator() {
        return creator;
    }

    /**
     * @return the lastModifyTime
     */
    public Date getLastModifyTime() {
        return lastModifyTime;
    }

    /**
     * @return the lastOperator
     */
    public Long getLastOperator() {
        return lastOperator;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param supplier the supplier to set
     */
    public void setSupplier(Supplier supplier) {
        this.supplier = supplier;
    }

    /**
     * @param keyPost the keyPost to set
     */
    public void setKeyPost(KeyPost keyPost) {
        this.keyPost = keyPost;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @param telephone the telephone to set
     */
    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    /**
     * @param mobile the mobile to set
     */
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    /**
     * @param email the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * @param tencent the tencent to set
     */
    public void setTencent(String tencent) {
        this.tencent = tencent;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(Boolean disabled) {
        this.disabled = disabled;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param creator the creator to set
     */
    public void setCreator(Long creator) {
        this.creator = creator;
    }

    /**
     * @param lastModifyTime the lastModifyTime to set
     */
    public void setLastModifyTime(Date lastModifyTime) {
        this.lastModifyTime = lastModifyTime;
    }

    /**
     * @param lastOperator the lastOperator to set
     */
    public void setLastOperator(Long lastOperator) {
        this.lastOperator = lastOperator;
    }


}
